// import { request } from "@/utils/request";
import { request } from "../../utils/http";

export const signApi = {
  /**
   * @description 查询当前医生的居民签约信息
   */
  getNowDrSignInfo: (
    data: { doctorId: string; limit: string },
    config: any = {}
  ) => {
    return request.post<SignResidentType>(
      "/api/getServiceByDIdLimit",
      data,
      config
    );
  },
  /**
   * @description (特详细)根据医生id和居民id查询指定状态的签约服务包信息
   * @param   residentId   居民id
   * @param    doctorId    当前登录医生id
   */
  getCurrentResidenInfo: (residentId: string, doctorId: string) => {
    return request.post<SignResidentType[]>("/api/getServiceByDIdRidStatus", {
      residentId: residentId,
      doctorId: doctorId,
    });
  },
  /***
   * @description 更新居民的签约订单的签约信息
   * @param   orderId   签约服务包id
   * @param   status    想要更改成啥种状态
   * @param   status    状态，待审核为0，待支付为1，已驳回为2，生效中为3，已过期为4，默认0
   */
  updateSignStatusById: (orderId: string, status: string) => {
    console.debug(orderId, "id");
    console.debug(status, "状态");
    return request.post("/api/updateSignStatusById", {
      id: orderId,
      status: status,
    });
  },
  /***
   * @description 居民签约
   * @param   data   签约的详情信息
   */
  saveSign: (data: any) => {
    return request.post("/api/saveSign", {
      ...data,
    });
  },
  /**
   * @description 获取签约详情
   * @param data
   * @returns
   */
  getSignDetail: (data: { id: string }) => {
    return request.post("/api/getSignById", data);
  },
};

/**
 * @description  居民信息列表
 */

export interface SignResidentType {
  id: string;
  doctorId: string;
  flag: number;
  notes: string;
  number: string;
  organId: string;
  resident: Resident;
  residentId: string;
  service: Service;
  serviceId: string;
  status: number;
  subscribeTime: string;
  takingEffectTime: string;
  team: Team;
  teamId: string;
  type: string;
  [property: string]: any;
}

export interface Resident {
  address: string;
  birthday: string;
  career: string;
  createTime: string;
  designatedMedicalUnits: string;
  district: string;
  educationId: string;
  emergencyContact: string;
  emergencyNumber: string;
  expenseTypeId: string;
  flag: number;
  gender: number;
  id: string;
  IDCard: string;
  maritalStatusId: string;
  name: string;
  nationId: string;
  nativePlace: string;
  number: string;
  origin: string;
  picture: string;
  residenceAddress: string;
  residenceId: string;
  status: number;
  tel: string;
  userId: string;
  workUnit: string;
  [property: string]: any;
}

export interface Service {
  description: string;
  flag: number;
  id: string;
  name: string;
  period: number;
  picture: string;
  price: number;
  renewal: number;
  serviceDetail: string;
  targetAudience: string;
  typeId: string;
  [property: string]: any;
}

export interface Team {
  flag: number;
  id: string;
  name: string;
  number: string;
  organId: string;
  picture: string;
  score: number;
  shareCount: number;
  status: number;
  [property: string]: any;
}

/**@description 居民的签约详情 */
export interface ResidentSignInfo {
  id: string;
  number: string;
  userId: string;
  name: string;
  picture: string;
  IDCard: string;
  tel: string;
  address: string;
  district: string;
  gender: number;
  birthday: string;
  residenceId: string;
  nativePlace: string;
  residenceAddress: string;
  nationId: string;
  educationId: string;
  maritalStatusId: string;
  career: string;
  workUnit: string;
  emergencyContact: string;
  emergencyNumber: string;
  expenseTypeId: string;
  designatedMedicalUnits: string;
  origin: string;
  status: number;
  flag: number;
  createTime: string;
}

interface TeamInfo {
  id: string;
  number: string;
  name: string;
  picture: string;
  organId: string;
  score: number;
  shareCount: number;
  status: number;
  flag: number;
}

interface ServiceInfo {
  id: string;
  name: string;
  typeId: string;
  price: number;
  targetAudience: string;
  period: number;
  renewal: number;
  picture: string;
  description: string;
  serviceDetail: string;
  flag: number;
}

interface Data {
  id: string;
  residentId: string;
  number: string;
  status: number;
  organId: string;
  teamId: string;
  doctorId: string;
  serviceId: string;
  type: string;
  subscribeTime: string;
  takingEffectTime: string;
  notes: string;
  flag: number;
  resident: Resident;
  team: TeamInfo;
  service: ServiceInfo;
}
